home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / usr / share / pyshared / nevow / inevow.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2009-03-23  |  34KB  |  730 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''
  5. Nevow interface definitions.
  6. '''
  7. from zope.interface import Interface, Attribute
  8.  
  9. class IQ(Interface):
  10.     '''Interface for querying. Adapters implement this for objects which may
  11.     appear in the stan DOM to allow introspecting the DOM and finding nodes
  12.     with certain qualities.
  13.     '''
  14.     
  15.     def patternGenerator(pattern, default = None):
  16.         """Returns a pseudo-Tag which will generate clones of matching
  17.         pattern tags forever, looping around to the beginning when running
  18.         out of unique matches.
  19.  
  20.         If no matches are found, and default is None, raise an exception,
  21.         otherwise, generate clones of default forever.
  22.  
  23.         You can use the normal stan syntax on the return value.
  24.  
  25.         Useful to find repeating pattern elements. Example rendering
  26.         function:
  27.  
  28.         >>> def simpleSequence(context, data):
  29.         ...   pattern = IQ(context).patternGenerator('item')
  30.         ...   return [pattern(data=element) for element in data]
  31.         """
  32.         pass
  33.  
  34.     
  35.     def allPatterns(pattern):
  36.         """Return a list of all matching pattern tags, cloned.
  37.  
  38.         Useful if you just want to insert them in the output in one
  39.         place.
  40.  
  41.         E.g. the sequence renderer's header and footer are found with this.
  42.         """
  43.         pass
  44.  
  45.     
  46.     def onePattern(pattern):
  47.         '''Return a single matching pattern, cloned.
  48.         If there is more than one matching pattern or no matching patterns,
  49.         raise an exception.
  50.  
  51.         Useful in the case where you want to locate one and only one
  52.         sub-tag and do something with it.
  53.         '''
  54.         pass
  55.  
  56.     
  57.     def keyed(key):
  58.         """Locate the node with the key 'key', clone it, call fillSlots(key, clone)
  59.         and return the clone.
  60.  
  61.         This method lets you effectively locate and mutate a node in the DOM.
  62.         It is useful for setting the data special on a specific node, and also for
  63.         calling fillSlots on a specific node, as well as other node-mutation operations
  64.         such as setting a handler or assigning a class or id to a node.
  65.         """
  66.         pass
  67.  
  68.  
  69.  
  70. class IResource(Interface):
  71.     
  72.     def locateChild(ctx, segments):
  73.         '''
  74.         Locate another object which can be adapted to IResource.
  75.  
  76.         @param ctx: The context object for the request being responded to.
  77.         @param segments: A tuple of strings giving the remaining query segments
  78.             to resolve into an IResource.
  79.  
  80.         @return: A two-tuple of an L{IResource} provider and a tuple giving the
  81.             query segments which remain to be processed.  A L{Deferred} which
  82.             is called back with such a two-tuple may also be returned.
  83.         '''
  84.         pass
  85.  
  86.     
  87.     def renderHTTP(ctx):
  88.         '''Render a request
  89.         '''
  90.         pass
  91.  
  92.  
  93.  
  94. class IRenderer(Interface):
  95.     """Things implementing this interface are serialized by calling their
  96.     'rend' method.
  97.     """
  98.     
  99.     def rend(ctx, data):
  100.         '''Turn this instance into stan suitable for displaying it in a web page.
  101.         '''
  102.         pass
  103.  
  104.  
  105.  
  106. class IRendererFactory(Interface):
  107.     '''A renderer factory is capable of taking a renderer directive (a string)
  108.     and returning a callable which when called, will render a portion of DOM.
  109.     '''
  110.     
  111.     def renderer(context, name):
  112.         '''Given a context object and a name, return a callable which responds
  113.         to the signature (context, data) or (data) and returns an object which
  114.         is flattenable.
  115.         '''
  116.         pass
  117.  
  118.  
  119.  
  120. class IMacroFactory(Interface):
  121.     '''A macro factory is capable of taking a macro directive (a string)
  122.     and returning a callable which when called, will replace the portion
  123.     of the DOM upon which the macro was placed with some different
  124.     DOM.
  125.     '''
  126.     
  127.     def macro(context, name):
  128.         '''Given a context object and a name, return a callable which responds
  129.         to the signature (context, *parameters) and returns an object which
  130.         is flattenable.
  131.         '''
  132.         pass
  133.  
  134.  
  135.  
  136. class IData(Interface):
  137.     '''Any python object to be used as model data to be passed
  138.     to view functions. Used for marking the context stack only.
  139.  
  140.     ANY python object is said to implement IData.
  141.     '''
  142.     pass
  143.  
  144.  
  145. class IGettable(Interface):
  146.     
  147.     def get(context):
  148.         '''Return the data
  149.  
  150.         Return any object
  151.         '''
  152.         pass
  153.  
  154.  
  155.  
  156. class ISettable(Interface):
  157.     
  158.     def set(context, data):
  159.         '''Set the data
  160.  
  161.         This might be removed.
  162.         '''
  163.         pass
  164.  
  165.  
  166.  
  167. class IContainer(Interface):
  168.     
  169.     def child(context, name):
  170.         '''Return a conceptual child; an attribute, or a key,
  171.         or the result of a function call.
  172.  
  173.         Returns any object; the result may be adapted to IGettable
  174.         if possible.
  175.  
  176.         Return None if the adaptee does not have a child with the
  177.         given name.
  178.  
  179.         TODO: Maybe returning None is bad, and .child should just
  180.         raise whatever exception is natural
  181.         '''
  182.         pass
  183.  
  184.  
  185.  
  186. class IComponentized(Interface):
  187.     '''I am a mixin to allow you to be adapted in various ways persistently.
  188.  
  189.     I define a list of persistent adapters.  This is to allow adapter classes
  190.     to store system-specific state, and initialized on demand.  The
  191.     getComponent method implements this.  You must also register adapters for
  192.     this class for the interfaces that you wish to pass to getComponent.
  193.  
  194.     Many other classes and utilities listed here are present in Zope3; this one
  195.     is specific to Twisted.
  196.     '''
  197.     
  198.     def setComponent(interfaceClass, component):
  199.         '''
  200.         Add a component to me for the indicated interface.
  201.         '''
  202.         pass
  203.  
  204.     
  205.     def addComponent(component, ignoreClass = 0, registry = None):
  206.         """
  207.         Add a component to me, for all appropriate interfaces.
  208.  
  209.         In order to determine which interfaces are appropriate, the component's
  210.         provided interfaces will be scanned.
  211.  
  212.         If the argument 'ignoreClass' is True, then all interfaces are
  213.         considered appropriate.
  214.  
  215.         Otherwise, an 'appropriate' interface is one for which its class has
  216.         been registered as an adapter for my class according to the rules of
  217.         getComponent.
  218.  
  219.         @return: the list of appropriate interfaces
  220.         """
  221.         pass
  222.  
  223.     
  224.     def getComponent(interface, registry = None, default = None):
  225.         """Create or retrieve an adapter for the given interface.
  226.  
  227.         If such an adapter has already been created, retrieve it from the cache
  228.         that this instance keeps of all its adapters.  Adapters created through
  229.         this mechanism may safely store system-specific state.
  230.  
  231.         If you want to register an adapter that will be created through
  232.         getComponent, but you don't require (or don't want) your adapter to be
  233.         cached and kept alive for the lifetime of this Componentized object,
  234.         set the attribute 'temporaryAdapter' to True on your adapter class.
  235.  
  236.         If you want to automatically register an adapter for all appropriate
  237.         interfaces (with addComponent), set the attribute 'multiComponent' to
  238.         True on your adapter class.
  239.         """
  240.         pass
  241.  
  242.     
  243.     def unsetComponent(interfaceClass):
  244.         '''Remove my component specified by the given interface class.'''
  245.         pass
  246.  
  247.     
  248.     def removeComponent(component):
  249.         '''
  250.         Remove the given component from me entirely, for all interfaces for which
  251.         it has been registered.
  252.  
  253.         @return: a list of the interfaces that were removed.
  254.         '''
  255.         pass
  256.  
  257.  
  258.  
  259. class ISession(IComponentized):
  260.     """A web session
  261.  
  262.     You can locate a Session object to represent a unique web session using
  263.     ISession(ctx). This default session implementation uses cookies to
  264.     store a session identifier in the user's browser.
  265.  
  266.     uid: Session uid
  267.  
  268.     TODO: Need better docs; what's a session and why and how do you use it
  269.     """
  270.     
  271.     def setLifetime(lifetime):
  272.         """Set the approximate lifetime of this session, in seconds.
  273.  
  274.         This is highly imprecise, but it allows you to set some general
  275.         parameters about when this session will expire.  A callback will be
  276.         scheduled each 'lifetime' seconds, and if I have not been 'touch()'ed
  277.         in half a lifetime, I will be immediately expired.
  278.  
  279.         If you need to change the lifetime of all the sessions change sessionsLifeTime
  280.         attribute in class guard.SessionWrapper
  281.         """
  282.         pass
  283.  
  284.     
  285.     def notifyOnExpire(callback):
  286.         '''Call this callback when the session expires or logs out.
  287.         '''
  288.         pass
  289.  
  290.     
  291.     def expire():
  292.         '''Expire/logout of the session.
  293.         '''
  294.         pass
  295.  
  296.     
  297.     def touch():
  298.         '''Refresh the session
  299.         '''
  300.         pass
  301.  
  302.  
  303.  
  304. class IGuardSession(ISession):
  305.     ''' A web session base interface
  306.     Needed for guard to do its dirty job
  307.  
  308.     guard: SessionWrapper object
  309.     '''
  310.     
  311.     def portalLogout(port):
  312.         '''Logout from portal port
  313.         '''
  314.         pass
  315.  
  316.  
  317.  
  318. class IRequest(IComponentized):
  319.     """A HTTP request.
  320.  
  321.     Subclasses should override the process() method to determine how
  322.     the request will be processed.
  323.  
  324.     @ivar method: The HTTP method that was used.
  325.     @ivar uri: The full URI that was requested (includes arguments).
  326.     @ivar path: The path only (arguments not included).
  327.     @ivar args: All of the arguments, including URL and POST arguments.
  328.     @type args: A mapping of strings (the argument names) to lists of values.
  329.                 i.e., ?foo=bar&foo=baz&quux=spam results in
  330.                 {'foo': ['bar', 'baz'], 'quux': ['spam']}.
  331.     @ivar received_headers: All received headers
  332.     """
  333.     
  334.     def getHeader(key):
  335.         '''Get a header that was sent from the network.
  336.  
  337.         Return C{None} if the header is not present.
  338.         '''
  339.         pass
  340.  
  341.     
  342.     def getCookie(key):
  343.         '''Get a cookie that was sent from the network.
  344.         '''
  345.         pass
  346.  
  347.     
  348.     def getAllHeaders():
  349.         '''Return dictionary of all headers the request received.'''
  350.         pass
  351.  
  352.     
  353.     def getRequestHostname():
  354.         '''Get the hostname that the user passed in to the request.
  355.  
  356.         This will either use the Host: header (if it is available) or the
  357.         host we are listening on if the header is unavailable.
  358.         '''
  359.         pass
  360.  
  361.     
  362.     def getHost():
  363.         """Get my originally requesting transport's host.
  364.  
  365.         Don't rely on the 'transport' attribute, since Request objects may be
  366.         copied remotely.  For information on this method's return value, see
  367.         twisted.internet.tcp.Port.
  368.         """
  369.         pass
  370.  
  371.     
  372.     def getClientIP():
  373.         pass
  374.  
  375.     
  376.     def getClient():
  377.         pass
  378.  
  379.     
  380.     def getUser():
  381.         pass
  382.  
  383.     
  384.     def getPassword():
  385.         pass
  386.  
  387.     
  388.     def isSecure():
  389.         pass
  390.  
  391.     
  392.     def getSession(sessionInterface = None):
  393.         pass
  394.  
  395.     
  396.     def URLPath():
  397.         pass
  398.  
  399.     
  400.     def prePathURL():
  401.         pass
  402.  
  403.     
  404.     def rememberRootURL():
  405.         '''
  406.         Remember the currently-processed part of the URL for later
  407.         recalling.
  408.         '''
  409.         pass
  410.  
  411.     
  412.     def getRootURL():
  413.         '''
  414.         Get a previously-remembered URL.
  415.         '''
  416.         pass
  417.  
  418.     
  419.     def finish():
  420.         '''We are finished writing data.'''
  421.         pass
  422.  
  423.     
  424.     def write(data):
  425.         '''
  426.         Write some data as a result of an HTTP request.  The first
  427.         time this is called, it writes out response data.
  428.         '''
  429.         pass
  430.  
  431.     
  432.     def addCookie(k, v, expires = None, domain = None, path = None, max_age = None, comment = None, secure = None):
  433.         '''Set an outgoing HTTP cookie.
  434.  
  435.         In general, you should consider using sessions instead of cookies, see
  436.         twisted.web.server.Request.getSession and the
  437.         twisted.web.server.Session class for details.
  438.         '''
  439.         pass
  440.  
  441.     
  442.     def setResponseCode(code, message = None):
  443.         '''Set the HTTP response code.
  444.         '''
  445.         pass
  446.  
  447.     
  448.     def setHeader(k, v):
  449.         '''Set an outgoing HTTP header.
  450.         '''
  451.         pass
  452.  
  453.     
  454.     def redirect(url):
  455.         '''Utility function that does a redirect.
  456.  
  457.         The request should have finish() called after this.
  458.         '''
  459.         pass
  460.  
  461.     
  462.     def setLastModified(when):
  463.         '''Set the X{Last-Modified} time for the response to this request.
  464.  
  465.         If I am called more than once, I ignore attempts to set
  466.         Last-Modified earlier, only replacing the Last-Modified time
  467.         if it is to a later value.
  468.  
  469.         If I am a conditional request, I may modify my response code
  470.         to L{NOT_MODIFIED} if appropriate for the time given.
  471.  
  472.         @param when: The last time the resource being returned was
  473.             modified, in seconds since the epoch.
  474.         @type when: number
  475.         @return: If I am a X{If-Modified-Since} conditional request and
  476.             the time given is not newer than the condition, I return
  477.             L{http.CACHED<CACHED>} to indicate that you should write no
  478.             body.  Otherwise, I return a false value.
  479.         '''
  480.         pass
  481.  
  482.     
  483.     def setETag(etag):
  484.         '''Set an X{entity tag} for the outgoing response.
  485.  
  486.         That\'s "entity tag" as in the HTTP/1.1 X{ETag} header, "used
  487.         for comparing two or more entities from the same requested
  488.         resource."
  489.  
  490.         If I am a conditional request, I may modify my response code
  491.         to L{NOT_MODIFIED<twisted.protocols.http.NOT_MODIFIED>} or
  492.         L{PRECONDITION_FAILED<twisted.protocols.http.PRECONDITION_FAILED>},
  493.         if appropriate for the tag given.
  494.  
  495.         @param etag: The entity tag for the resource being returned.
  496.         @type etag: string
  497.         @return: If I am a X{If-None-Match} conditional request and
  498.             the tag matches one in the request, I return
  499.             L{CACHED<twisted.protocols.http.CACHED>} to indicate that
  500.             you should write no body.  Otherwise, I return a false
  501.             value.
  502.         '''
  503.         pass
  504.  
  505.     
  506.     def setHost(host, port, ssl = 0):
  507.         """Change the host and port the request thinks it's using.
  508.  
  509.         This method is useful for working with reverse HTTP proxies (e.g.
  510.         both Squid and Apache's mod_proxy can do this), when the address
  511.         the HTTP client is using is different than the one we're listening on.
  512.  
  513.         For example, Apache may be listening on https://www.example.com, and then
  514.         forwarding requests to http://localhost:8080, but we don't want HTML produced
  515.         by Twisted to say 'http://localhost:8080', they should say 'https://www.example.com',
  516.         so we do:
  517.  
  518.         >>> request.setHost('www.example.com', 443, ssl=1)
  519.  
  520.         This method is experimental.
  521.         """
  522.         pass
  523.  
  524.  
  525.  
  526. class ISerializable(Interface):
  527.     '''DEPRECATED. Use nevow.flat.registerFlattener instead of registering
  528.     an ISerializable adapter.
  529.     '''
  530.     
  531.     def serialize(context):
  532.         '''Serialize the adaptee, with the given context
  533.         stack if necessary.
  534.         '''
  535.         pass
  536.  
  537.  
  538.  
  539. class IStatusMessage(Interface):
  540.     """A marker interface, which should be set on the user's web session
  541.     to an object which can be cast to a string, which will be shown to the
  542.     user to indicate the status of the most recent operation.
  543.     """
  544.     pass
  545.  
  546.  
  547. class IHand(Interface):
  548.     '''A marker interface which indicates what object the user is currently
  549.     holding in their hand. This is conceptually the "result" of the last operation;
  550.     this interface can be used to mark a status string which indicates whether
  551.     the most recent operation completed successfully, or can be used to hold
  552.     an object which resulted from the most recent operation.
  553.     '''
  554.     pass
  555.  
  556.  
  557. class ICanHandleException(Interface):
  558.     
  559.     def renderHTTP_exception(context, failure):
  560.         '''Render an exception to the given request object.
  561.         '''
  562.         pass
  563.  
  564.     
  565.     def renderInlineException(context, reason):
  566.         '''Return stan representing the exception, to be printed in the page,
  567.         not replacing the page.'''
  568.         pass
  569.  
  570.  
  571.  
  572. class ICanHandleNotFound(Interface):
  573.     
  574.     def renderHTTP_notFound(context):
  575.         '''Render a not found message to the given request.
  576.         '''
  577.         pass
  578.  
  579.  
  580.  
  581. class IEventMaster(Interface):
  582.     pass
  583.  
  584.  
  585. class IDocFactory(Interface):
  586.     """Interface for objects that load and parse templates for Nevow's
  587.     renderers.
  588.  
  589.     The load method's context arg is optional. Loaders should be written to cope
  590.     with no context arg and either create a new context (if necessary) or raise
  591.     a ValueError if the context of the caller is important.
  592.  
  593.     If a context is passed to load() it should *not* be passed on to the
  594.     flattener/precompiler; a new context should be created if necessary. This
  595.     measure is to ensure that nothing remembered in the caller's context, i.e.
  596.     personal information in the session, leaks into the template until it is
  597.     actually rendered.
  598.     """
  599.     
  600.     def load(ctx = None, preprocessors = ()):
  601.         '''
  602.         Load a template and return a stan document tree.
  603.  
  604.         @param preprocessors: An iterable of one-argument callables which will
  605.         be given the stan document tree to transform before it is compiled.
  606.         '''
  607.         pass
  608.  
  609.  
  610.  
  611. class ISession(Interface):
  612.     """A web session
  613.  
  614.     You can locate a Session object to represent a unique web session using
  615.     ctx.locate(ISession). This default session implementation uses cookies to
  616.     store a session identifier in the user's browser.
  617.  
  618.     TODO: Need better docs; what's a session and why and how do you use it
  619.     """
  620.     pass
  621.  
  622.  
  623. class IRemainingSegments(Interface):
  624.     '''During the URL traversal process, requesting this from the context
  625.     will result in a tuple of the segments remaining to be processed.
  626.  
  627.     Equivalent to request.postpath in twisted.web
  628.     '''
  629.     pass
  630.  
  631.  
  632. class ICurrentSegments(Interface):
  633.     '''Requesting this from the context will result in a tuple of path segments
  634.     which have been consumed to reach the current Page instance during
  635.     the URL traversal process.
  636.  
  637.     Equivalent to request.prepath in twisted.web
  638.     '''
  639.     pass
  640.  
  641.  
  642. class IViewParameters(Interface):
  643.     '''An interface used by url.viewhere. When this interface is remembered
  644.     above a url.viewhere embedded in a page, and the url to the current page
  645.     is rendered, this object will be consulted for additional manipulations
  646.     to perform on the url object before returning it.
  647.     '''
  648.     
  649.     def __iter__():
  650.         """Return an iterator which yields a series of (command, args, kw) triples,
  651.         where 'command' is a string, indicating which url method to call, 'args' is a
  652.         list indicating the arguments to be passed to this method, and 'kw' is a dict
  653.         of keyword arguments to pass to this method.
  654.         """
  655.         pass
  656.  
  657.  
  658.  
  659. class II18NConfig(Interface):
  660.     '''
  661.     Interface for I18N configuration.
  662.  
  663.     @ivar domain: the gettext domain
  664.  
  665.     @type domain: str
  666.  
  667.     @ivar localeDir: path to the messages files or None to use the
  668.     system default
  669.  
  670.     @type localeDir: str or None
  671.     '''
  672.     domain = Attribute('The gettext domain')
  673.     localeDir = Attribute('Path to the messages files or None to use the system default')
  674.  
  675.  
  676. class ILanguages(Interface):
  677.     '''
  678.     Marker interface for the sequence of strings that defines the
  679.     languages requested by the user.
  680.     '''
  681.     pass
  682.  
  683.  
  684. class ILogger(Interface):
  685.     '''
  686.     An access.log writing interface.
  687.  
  688.     Remember this interface in the context stack to use alternative
  689.     logging for the resources below that point in the tree.
  690.     '''
  691.     
  692.     def log(ctx):
  693.         '''Write a log entry for this request.'''
  694.         pass
  695.  
  696.  
  697.  
  698. class IJavascriptPackage(Interface):
  699.     '''
  700.     Represents information about the filesystem layout of a set of
  701.     JavaScript modules.
  702.  
  703.     @ivar mapping: A C{dict} mapping C{str} to C{str}.  The keys in
  704.     this dictionary are JavaScript module names which can be imported by
  705.     JavaScript files server by C{nevow.athena.LivePage}.  The values give
  706.     locations in the filesystem where the implementation of each module can
  707.     be found.
  708.     '''
  709.     pass
  710.  
  711.  
  712. class IAthenaTransportable(Interface):
  713.     '''
  714.     An object which can be sent by Athena from the Python server to the
  715.     JavaScript client.
  716.     '''
  717.     jsClass = Attribute('\n        A C{unicode} string giving the fully-qualified name of a JavaScript\n        function which will be invoked to unserialize the serialized form of\n        this object.\n\n        The current serialization implementation is limited to supporting\n        values for this attribute which refer to JavaScript functions which\n        are defined in modules which have already been imported by the\n        client receiving the serialized data.  An attempt to lift this\n        limitation will likely be made at some future point.\n        ')
  718.     
  719.     def getInitialArguments():
  720.         '''
  721.         Define the arguments which will be passed to L{jsClass}.
  722.  
  723.         @rtype: L{tuple}
  724.         @return: A tuple of simple types which will be passed as positional
  725.             arguments to L{jsClass}.
  726.         '''
  727.         pass
  728.  
  729.  
  730.